package cn.tedu.serviceEdu.controller.front;

import cn.tedu.commonUtils.R;
import cn.tedu.serviceEdu.entity.EduCourse;
import cn.tedu.serviceEdu.entity.EduTeacher;
import cn.tedu.serviceEdu.service.EduCourseService;
import cn.tedu.serviceEdu.service.EduTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("/eduservice/frontindex")
@CrossOrigin
public class FrontIndexController {

    @Autowired
    private EduTeacherService teacherService;

    @Autowired
    private EduCourseService courseService;

    @GetMapping("/index")
    public R index() {
        //查询最新前4条讲师数据
        //查询最新前8条课程数据
        List<EduTeacher> teacherList =  teacherService.getIndexTeacherList();
        List<EduCourse> courseList = courseService.getIndexCourseList();
        HashMap<String, Object> map = new HashMap<>();
        map.put("teacherList",teacherList);
        map.put("courseList",courseList);
         return R.ok().data(map);
    }
}
